/**
 * Created with IntelliJ IDEA.
 * Description: 2023次方
 * User: DELL
 * Date: 2024-05-09
 * Time: 14:35
 */
public class Main2 {
    static int MOD = 2023;

    public static void main(String[] args) {
        int ans = 2023;
        for (int i = 2022; i >= 2; i--) {
            ans = fastPow(i, ans);
        }
        System.out.println(ans);
    }

    private static int fastPow(int num, int pow) {
        int ans = 1;
        while (pow != 0) {
            if ((pow & 1) == 1) {
                ans *= num;
                ans %= MOD;
            }
            num *= num;
            num %= MOD;
            pow >>= 1;
        }
        return ans;
    }
}
